package com.youuvs.controller;

import com.youuvs.domain.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@RestController
@RequestMapping("/order")
public class OrderController {

    @Autowired
    private RestTemplate restTemplate;

    @GetMapping("/getById/{id}")
    public User getById(@PathVariable("id") Long id){
        //跳转到user服务,调用user的接口
        String url = "http://user-server/user/getById/"+id;
        return restTemplate.getForObject(url,User.class);
    }
}
